package com.cruise.h5.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cruise.common.web.result.Result;
import com.cruise.h5.pojo.dto.CollectDTO;
import com.cruise.h5.pojo.dto.VideoCollectionListDTO;
import com.cruise.h5.pojo.vo.VideoListVO;
import com.cruise.h5.service.VideoCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cruise
 * @since 2021-04-19
 */
@Api(tags = "视频收藏")
@RestController
@RequestMapping("/h5/video-collection")
public class VideoCollectionController {

    @Resource
    private VideoCollectionService videoCollectionService;

    @ApiOperation("查询收藏列表")
    @PostMapping("/getVideoCollectionList")
    public Result<IPage<VideoListVO>> getVideoCollectionList(@RequestBody VideoCollectionListDTO videoCollectionListDTO){
        IPage<VideoListVO> videoListVoIpage = videoCollectionService.getVideoCollectionList(videoCollectionListDTO);
        return Result.success(videoListVoIpage);
    }



    /**
     * 添加收藏 和 移除收藏
     * @param collectDTO
     * @return
     */
    @ApiOperation("添加收藏 和 移除收藏")
    @PostMapping("/collect")
    public Result collect(@RequestBody CollectDTO collectDTO){
        Integer collectCount = videoCollectionService.collect(collectDTO);
        return Result.success(collectCount);
    }


}

